package com.imooc.InterceptorConfig;

import com.imooc.Interceptor.JwtCurrentUserInterceptor;
import com.imooc.Interceptor.SMSInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author liansen
 * @create 12-23-12:56
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public SMSInterceptor getSMSInterceptor(){
        return new SMSInterceptor();
    }

    @Bean
    public JwtCurrentUserInterceptor jwtCurrentUserInterceptor(){
        return new JwtCurrentUserInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getSMSInterceptor())
                .addPathPatterns("/passport/getSMSCode");


        registry.addInterceptor(jwtCurrentUserInterceptor())
                .addPathPatterns("/**").order(1);

    }
}
